/**
 * 格式化请求的参数
*/
export function tansParams(params) {
	let result = ''
	let keys = 
	Object.keys(params).forEach((key, index, arr)=>{
		const value = params[key]
		var part = encodeURIComponent(key)+'='
		
		if(value !== null && value !== "" && typeof(value) !== "undefined") {
			if(typeof value === 'object') {
				
				for(const k of Object.keys(value)) {
					if (value[k] !== null && value[k] !== "" && typeof(value[k]) !== "undefined") {
						let param = `${key}\[${ k }\]`
						var subPart = encodeURIComponent(param) + "=";
						result += subPart + encodeURIComponent(value[k]) + '&'
					}
				}
				
			} else if (arr.length - 1 > index) {
				result += part + encodeURIComponent(value) + "&"
			} else {
				result += part + encodeURIComponent(value)
			}
		}
	})
	return result
}